package com.slliver;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.TimeUnit;

@SpringBootApplication
public class NacosConfigApplication {

    public static void main(String[] args) throws InterruptedException {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(NacosConfigApplication.class, args);
        while (true) {
            String datasourceType = applicationContext.getEnvironment().getProperty("spring.datasource.type");
            String datasourceDriverClassName = applicationContext.getEnvironment().getProperty("spring.datasource.driver-class-name");
            String datasourceUrl = applicationContext.getEnvironment().getProperty("spring.datasource.url");
            String datasourceUsername = applicationContext.getEnvironment().getProperty("spring.datasource.username");
            String datasourcePassword = applicationContext.getEnvironment().getProperty("spring.datasource.password");

            String redisHost = applicationContext.getEnvironment().getProperty("spring.redis.host");
            String redisPort = applicationContext.getEnvironment().getProperty("spring.redis.port");

            String rabbitmqHost = applicationContext.getEnvironment().getProperty("spring.rabbitmq.host");
            String rabbitmqPort = applicationContext.getEnvironment().getProperty("spring.rabbitmq.port");

            String esHost = applicationContext.getEnvironment().getProperty("spring.es.host");
            String esPort = applicationContext.getEnvironment().getProperty("spring.es.port");

            String dockerHost = applicationContext.getEnvironment().getProperty("spring.docker.host");
            String dockerPort = applicationContext.getEnvironment().getProperty("spring.docker.port");
            System.err.println("spring datasource type :" + datasourceType + "\n"
                    + "; datasourceDriverClassName: " + datasourceDriverClassName + "\n"
                    + "; datasourceUrl: " + datasourceUrl + "\n"
                    + "; datasourceUsername: " + datasourceUsername + "\n"
                    + "; datasourcePassword: " + datasourcePassword + "\n"
                    + "; redisHost: " + redisHost + "\n"
                    + "; redisPort: " + redisPort + "\n"
                    + "; rabbitmqHost: " + rabbitmqHost + "\n"
                    + "; rabbitmqPort: " + rabbitmqPort + "\n"
                    + "; esHost: " + esHost + "\n"
                    + "; esPort: " + esPort + "\n"
                    + "; dockerHost: " + dockerHost + "\n"
                    + "; dockerPort: " + dockerPort
            );
            TimeUnit.SECONDS.sleep(1);
        }
    }

}
